<?php 
$currentPage = isset($_REQUEST['curPage'])?$_REQUEST['curPage']:1;
$start = ($currentPage	-1) * $pagesize;	
$strSQL = "SELECT * FROM san where 1 LIMIT  $start, $pagesize";
$result = mysql_query($strSQL);
while($r3 = mysql_fetch_assoc($result))
{
	$id=$r3["SanID"];
			$tieude=$r3["TieuDe"];
			$mota=$r3["MoTa"];
			$hinh=$r3["Hinh"];
?>
<div class="rightcontentsan001">
<div class="rightcontentimg"><img src="images/san/<?php echo "$hinh"; ?>" width="200"  height="160" /></div>
<div class="rightcontentdetail">
   <div><?php echo $id;?></div>
   <div class="rightcontenttitle"><b><?php echo "$tieude";?></b></div>
   <div class="rightcontentdes">
	<span><a href='?action=datsan&sanid=<?php echo "$id"; ?>'>Đặt Sân</a></span>
    <span><a href='?action=chitietsan&sanid=<?php echo "$id"; ?>'>Xem mô tả sân</a></span>
   </div>
</div>
</div>
<?php
}
?>

 <?php
$query = "SELECT count(*) as NUMROW FROM san where 1 ";
$result = mysql_query($query);	
$row = mysql_fetch_array($result);
$numrow = $row[0];
$numpage = ceil($numrow / ($pagesize*1.0));

//Style 
echo "<h2>";
if ($numpage>1)
{
	$next = $currentPage + 1;
     $prev = $currentPage - 1;
	 if($currentPage!=1)
	 		echo "<a style='cursor:pointer'href='?action=san&curPage=$prev'>Previous</a>&nbsp;&nbsp;&nbsp;"   ;  
for($i = 1 ; $i<= $numpage;$i++)
{
	if($i == $currentPage)
		echo $i."&nbsp;&nbsp;&nbsp;";
	else
	{
		echo "<a style='cursor:pointer' href='?action=san&curPage=$i'>".$i."</a>&nbsp;&nbsp;&nbsp;";
	}
}
	 if($currentPage != $numpage)
            echo "<a style='cursor:pointer' href='?action=san&curPage=$next'>Next</a>";
		echo "</h2>";
}
?>